<template>
	<view class="search">
		<top-bar :hot="hot"></top-bar>
		<search-history :search_history="history"></search-history>
		<hot-search :hot_search="hot_search"></hot-search>
	</view>
</template>
 
<script>
	import TopBar from "./TopBar"
	import SearchHistory from "./SearchHistry"
	import HotSearch from "./HotSearch"
	
	import {hotSearch} from "@/network/axios/search/hotSearch"
	
	export default {
		name: '',
		data(){
			return {
				history: [],
				hot_search: [],
				hot: ""
			}
		},
		components: { TopBar, SearchHistory, HotSearch },
		methods:{
		},
		onLoad() {
			//获取搜索历史
			for(let i in window.localStorage) {
				if(i.slice(0,5) === "music") {
					this.history.push(window.localStorage.getItem(i))
				}
			}
			//获取热搜列表
			hotSearch().then((res) => {
				this.hot_search = res.data.result.hots
				this.hot = this.hot_search[0].first
			})
		}
	}
</script>
 
<style lang="less" scoped>
</style>
